Specright Specification to Product System API icon

Specright Specification to Product System API

(0 reviews)

Error Codes

Specright Specification to Product System API data validation will be composed of the error handling mechanism where the user and Api owner is notified as soon as something is wrong.

This API uses conventional HTTP response codes to indicate the success or failure of an API request.

In general: Codes in the 2xx range indicate success. Codes in the 4xx range indicate an error that failed given the information provided (e.g., a required field was omitted). Codes in the 5xx range indicate an error with the server.

HTTP Status Code Summary
Status CodeDescription
200Success / OK
201Created
204No Content
400Bad Request The server could not understand the request due to invalid syntax.
401Unauthorized Invalid token. The server was unable to authenticate the user.
403Forbidden
404Not Found
405Method Not Allowed
412Precondition Failed Failed updating resource due to invalid If-Match.
415Unsupported Media Type The media format of the requested data is not supported by the server.
428Precondition Required Required header 'If-Match' not provided.
500Internal Server Error An internal server error was observed.
502Bad Gateway The server encountered received an invalid response from an inbound server it accessed while attempting to fulfil the request.
503Service Unavailable The server was unable to handle the request due to a temporary overloading or maintenance of the server.
504Gateway Timeout
Business Error Handling

In our API, we handle business errors using specific error codes to identify and manage different scenarios. Below are some common business error codes:

Illustrative examples -

  • BUSINESS_VALIDATION_ERROR: This error occurs when a business rule is violated.
    • Error Code: BUSINESS_VALIDATION_ERROR
    • Description: The provided data does not meet the business validation criteria.
    • Example:{"errorCode": "BUSINESS_VALIDATION_ERROR","message": "The age must be less than 30."}
  • INSUFFICIENT_FUNDS: This error occurs when an account does not have enough funds to complete a transaction.
    • Error Code: INSUFFICIENT_FUNDS
    • Description: The account balance is insufficient for the requested operation.
    • Example:{"errorCode": "INSUFFICIENT_FUNDS","message": "Your account does not have enough funds to complete this transaction."}
  • ENTITY_NOT_FOUND: This error occurs when a requested entity is not found in the system.
    • Error Code: ENTITY_NOT_FOUND
    • Description: The requested entity does not exist.
    • Example:{"errorCode": "ENTITY_NOT_FOUND","message": "The user with ID 12345 was not found."}
Error Handling Approach

Our API several error handling strategies to ensure robustness and reliability.

Custom Policies for Error Scenarios

Illustrative examples -

Retry Mechanism

We implement a retry mechanism to handle transient errors, such as temporary network issues. This mechanism retries the operation a specified number of times before failing.

Example:

retry:

count: 3

interval: 2000 # in milliseconds


Reviews